package com.wsoft.form.controller;

import com.wsoft.form.dto.WfFormTableRelationDTO;
import com.wsoft.form.service.IWfFormTableRelationService;
import com.wsoft.response.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 自定义表单-数据关联表 前端控制器
 * </p>
 *
 * @author Z001
 * @since 2024年09月05日 08:04:10
 */
@RestController
@Tag(name = "表字段关联-删除")
@RequestMapping("/wf/relation")
public class WfFormTableRelationController {

    @Resource
    private IWfFormTableRelationService relationService;

    @Operation(summary = "新增表/修改表字段关联", description = "新增表/修改表字段关联")
    @PostMapping("/addOrUpdateColumnRelation")
    public ResponseResult addOrUpdateColumnRelation(@RequestBody WfFormTableRelationDTO dto) {
        boolean b = relationService.addOrUpdateColumnRelation(dto);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }

    @Operation(summary = "删除表字段关联", description = "删除表字段关联")
    @GetMapping("/delColumnRelation")
    public ResponseResult delColumnRelation(@RequestParam("id") Long id, @RequestParam("formId") Long formId) {
        boolean b = relationService.delColumnRelation(id,formId);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }
}
